const { Types } = require("mongoose");
const mongoose = require("./db");

let userSchema = new mongoose.Schema({
  username:String,
  name:String,
  password:String,
  address:String,
  phone:String,
  email:String,
  img:String,
})

let cateSchema= new mongoose.Schema({
  name:String,
  img:String,
})

let starSchema= new mongoose.Schema({
  name:String,
})


let addressSchema= new mongoose.Schema({
  name:String,
  address:String,
  phone:String,
  diqu: String,
  xiangxidizhi: String,
  status:{
    type:Boolean,
    default:false
  }
})

let listSchema = new mongoose.Schema({
  name:String,
  price:Number,
  img:String,
  cate:String,
  desc:String,//介绍
  num:Number,//参与者数量
  status:{
    type:Boolean,
    default:false
  },//状态
  isCheck:{
    type:Boolean,
    default:false
  },//活动状态
  time:String,//时间
  address:String,//地点
  cate:{
    type:mongoose.Types.ObjectId,
    ref:'cate'//类别
  },
  star:{
    type:[mongoose.Types.ObjectId],
    ref:'star'//明星  
  }
})

let dingdanSchema = new mongoose.Schema({
  name:String,
  price:Number,
  img:String,
  cate:String,
  desc:String,//介绍
  num:Number,//参与者数量
  status:Boolean,
  time:String,//时间
  address:String,//地点
  username:String,
  phone:String,
  address:String,
  diqu: String,
})


let shoucangSchema = new mongoose.Schema({
  name:String,
  price:Number,
  img:String,
  cate:String,
  desc:String,//介绍
  num:Number,//参与者数量
  status:Boolean,
  time:String,//时间
  address:String,//地点
  username:String,
  phone:String,
  address:String,
  diqu: String,
  cate:{
    type:mongoose.Types.ObjectId,
    ref:'cate'//类别
  },
  star:{
    type:mongoose.Types.ObjectId,
    ref:'star'//明星  
  }
})

let ContextSchema= new mongoose.Schema({
  context:String,
  time:String,
  username:String,
})
let ChatSchema = new mongoose.Schema({
  msg: String,
  state: String,
  name: String,
});

let ChatModel = mongoose.model("chat", ChatSchema, "chat");
let userModel = mongoose.model("user",userSchema,'user');

let cateModel = mongoose.model("cate",cateSchema,'cate');

let starModel = mongoose.model("star",starSchema,'star');

let addressModel = mongoose.model("address",addressSchema,'address');

let listModel = mongoose.model("list",listSchema,'list');

let dingdanModel = mongoose.model("dingdan",dingdanSchema,'dingdan');

let shoucangModel = mongoose.model("shoucang",shoucangSchema,'shoucang');

let ContextModel = mongoose.model("context",ContextSchema,'context');
module.exports = {
  userModel,
  cateModel,
  starModel,
  addressModel,
  listModel,
  dingdanModel,
  shoucangModel,
  ContextModel,
  ChatModel
};
